/**
 * Created by WYH on 17/3/17.
 */
require.config({
    paths: {
        "jquery": "../../../lib/jquery-3.0.0",
        "dcalendar": "../../../lib/dcalendar.picker"
    }
});

require(['jquery', 'dcalendar'], function ($, dcalendar) {
    dcalendar.dcalendar($);
    var calendar = $("#calendar").dcalendar();

    //var community = null;
    //var manager = null;
    //var equipmentName = null;
    //var equipmentDescription = null;
    //this.beginTime = null;
    //this.endTime = null;
    //this.authorization = null;
    //this.isAvailable = null;

    var selectTimeEle = null;


    bindTimeClick($(".content-input-start-time"));
    bindTimeClick($(".content-input-end-time"));

    calendar.on('selectdate', function (result) {
        changeTime(selectTimeEle, result.date);
    });



    function changeTime(timeEle, time) {
        timeEle.val(time);
        selectTimeEle = null;
        $(".content-input-calendar").hide();
    }



    function bindTimeClick(element) {
        element.click(function () {
            if (!selectTimeEle || selectTimeEle != element) {
                selectTimeEle = element;
                $(".content-input-calendar").show();
            } else {
                selectTimeEle = null;
                $(".content-input-calendar").hide();
            }

        });
    }




});